package com.erp.erp_mask.vo;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;

@Data
public class Result {
    private Long code;
    private String msg;
    private Object data;
    private Long count;

    public static Result success(Object data) {
        Result result = new Result();
        result.setCode(200l);
        result.setData(data);
        return result;
    }

    public static Result success(String msg) {
        Result result = new Result();
        result.setCode(200l);
        result.setMsg(msg);
        return result;
    }

    public static Result fail(String msg) {
        Result result = new Result();
        result.setCode(500l);
        result.setMsg(msg);
        return result;
    }
    public static Result success(Page page) {
        Result result = new Result();
        result.setData(page.getRecords());
        result.setCount(page.getTotal());
        result.setCode(200l);
        return result;
    }
}